
#ifndef __CONGESTION_CONTROL_H
#define __CONGESTION_CONTROL_H

#include <map>
#include "RateControl.h"

/** Defines a probabilistic congestion control algorithm. */
class CongestionControl : public RateControl
{
   public:
      CongestionControl(int64_t ibytes_per_second,
         int iusec_ack_timeout, double icongestion_window_size=2.);
      void checkForTimeouts();
      int prepareForSend(int32_t packet_id, int datasize);
      int acknowledgementReceived(int32_t packet_id);
   protected:
      /** Proportion of packets requiring an acknowledgement. */
      double packet_prop;
      /** Set of packet yet to be acknowledged. */
      std::map<uint32_t, int64_t> congestion_window;
      /** Last increase in congestion_window size. */
      int64_t last_reset_ts;
      /** Timeout to receive acknowledgement. */
      int usec_ack_timeout;
};

#endif
